<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>
            欢迎界面
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="css/main.css" media="all">
        <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
        <link rel="stylesheet" href="lib/bootstrap/css/bootstrap.css" media="all">
        <link rel="stylesheet" href="lib/bootstrap/js/bootstrap.min.js" media="all">
    </head>
    <body>
    <style type="text/css">
	legend { display: block; width:100px; border-bottom:0px; font-family: "Microsoft YaHei","Helvetica Neue";}
	legend a{ color:#666;} legend a:hover{ text-decoration:none;}
	.layui-table{ font-family: "Microsoft YaHei","Helvetica Neue";}
	</style>
        <div class="x-body">
            <blockquote class="layui-elem-quote">
                医务管理系统后台<span class="f-14">v1.0</span> &nbsp;
            </blockquote>

            
            <fieldset class="layui-elem-field layui-field-title site-title">
              <legend><a name="default">信息统计</a></legend>
            </fieldset>

        <!--相关统计-->
        <div class="row">
        <div class="col-md-12">
         <section class="panel">
                    <div class="panel-heading">医生工作量统计</div>
             <br>
             <div >
                 <div style="display: inline"><input id="start_date" type="date" value="2022-01-01"></div>
                 <div style="display: inline"> <input id="end_date" type="date" value="2022-02-01"></div>
                <div style="display: inline;"> <button id="find_doctor" style="width: 50px" class="btn btn-info">查找</button></div>
             </div>


                    <div class="panel-body">
                        <div class="echarts" id="doctor_work" style="height:300px; height:350px"></div>
                    </div>
                </section>
        </div>

        <div class="col-md-6">
            <section class="panel">
                <div class="panel-heading">医生每日统计</div>
                <br>

                <div>
                    <div style="display: inline">
                        <input id="dc_input" type="text" value="2">
                        <button id="btn_findByDate" class="btn btn-info" style="width: 100px">查找工号</button>
                    </div>
                </div>

                <div class="panel-body">
                    <div class="echarts" id="doctor_workByDay" style="height:300px; height:350px"></div>
                </div>
            </section>
        </div>



            <div class="col-md-6">
                <section class="panel">
                    <div class="panel-heading">学生看病统计</div>
                    <br>



                    <div class="panel-body">
                        <div class="echarts" id="student_sc" style="height:300px; height:350px"></div>
                    </div>
                </section>
            </div>


        </div>
    
        <script src="lib/layui/layui.js" charset="utf-8"></script>\
        <script src="js/jquery.min.js"></script>
        <script src="js/echarts.min.js"></script>


            
        </div>
        <div class="layui-footer footer footer-demo">
            <div class="layui-main">
                <p>
                    <a href="">
                    </a>
                </p>
                
            </div>
        </div>
        
    </body>

<script>
    let myChart = echarts.init(document.getElementById("doctor_work"));
    myChart.setOption({

        title: {
            text: '医生工作量'
        },
        tooltip: {},
        xAxis: {
            name:"医生工号",
            data: []
        },
        yAxis: {},
        series: [
            {

                name: '诊断病人个数',
                type: 'bar',
                data: []
            }
        ]
    });
    myChart.showLoading();
    let dc_list = [];
    let num_list = [];
    $(function (){
        $.ajax({
            url:"/clinicReg/dc_count_bytime",
            type:"POST",
            data:{
                start:$("#start_date").val(),
                end:$("#end_date").val()
            },

            success: function(result){
                if(result.state == 200){
                    let dt = result.data;

                    $.each(dt,function (i) {
                        dc_list.push(dt[i].dc_ID);
                        num_list.push(dt[i].num);
                    });
                    myChart.hideLoading();
                    myChart.setOption({
                        xAxis: {data:dc_list},
                        series: [{
                            data:num_list
                        }]
                    });


                }

            }
        })
    });

    $("#find_doctor").click(function () {
        let dc_list = [];
        let num_list = [];
        $.ajax({
            url:"/clinicReg/dc_count_bytime",
            type:"POST",
            data:{
                start:$("#start_date").val(),
                end:$("#end_date").val()
            },

            success: function(result){
                if(result.state == 200){
                    let dt = result.data;
                    $.each(dt,function (i) {
                        dc_list.push(dt[i].dc_ID);
                        num_list.push(dt[i].num);
                    });
                    myChart.hideLoading();
                    myChart.setOption({
                        xAxis: {data:dc_list},
                        series: [{
                            data:num_list
                        }]
                    });


                }

            }
        })
    })


</script>

<script>
    let myChart2 = echarts.init(document.getElementById("doctor_workByDay"));
    myChart2.setOption({
        xAxis: {
            name:"日期",
            type: 'category',
            data: []
        },
        yAxis: {
            name:"工作量",
            type: 'value'
        },
        series: [
            {
                data: [],
                type: 'line'
            }
        ]

    });
    let date_list = [];
    let nums_list = [];
    myChart2.showLoading();

    $.ajax({
        url:"/clinicReg/dc_count_everyday",
        type:"POST",
        data:{
            dc_ID:$("#dc_input").val()
        },
        success:function (result){
            if(result.state == 200){

                let msg = result.data;
                $.each(msg,function (i) {
                    date_list.push(msg[i].dt);
                    nums_list.push(msg[i].num);
                });

                myChart2.hideLoading();

                myChart2.setOption({
                    xAxis: {data:date_list},
                    series: [{
                        data:nums_list
                    }]
                });

            }


        }
    })


    $("#btn_findByDate").click(function () {
        date_list = [];
        nums_list = [];
        $.ajax({
            url:"/clinicReg/dc_count_everyday",
            type:"POST",
            data:{
                dc_ID:$("#dc_input").val()
            },
            success:function (result){
                if(result.state == 200){

                    let msg = result.data;
                    $.each(msg,function (i) {
                        date_list.push(msg[i].dt);
                        nums_list.push(msg[i].num);
                    });

                    myChart2.hideLoading();

                    myChart2.setOption({
                        xAxis: {data:date_list},
                        series: [{
                            data:nums_list
                        }]
                    });

                }


            }
        })
    })


</script>


<script>
        let myChart3 = echarts.init(document.getElementById("student_sc"));
        myChart3.setOption({


            tooltip: {},
            xAxis: {
                name:"学生学号",
                data: []
            },
            yAxis: {},
            series: [
                {

                    name: '学生看病次数',
                    type: 'bar',
                    data: []
                }
            ]
        });
        myChart3.showLoading();
        let st_list = [];
        let st_num_list = [];
        $(function (){
            $.ajax({
                url:"/clinicReg/st_count",
                type:"POST",
                data:{
                    start:$("#start_date").val(),
                    end:$("#end_date").val()
                },

                success: function(result){
                    if(result.state == 200){
                        let st = result.data;
                        console.log(st);

                        $.each(st,function (i) {
                            console.log(st[i].st_ID);
                            st_list.push(st[i].st_ID);
                            st_num_list.push(st[i].num);
                        });
                        myChart3.hideLoading();
                        myChart3.setOption({
                            xAxis: {data:st_list},
                            series: [{
                                data:st_num_list
                            }]
                        });


                    }

                }
            })
        });



    </script>
</html>